//
//  MainHomePageTabBarSubView.swift
//  FrameProduct
//
//  Created by delegate on 2025/10/20.
//

import UIKit

class MainHomePageTabBarSubView: UIView {
    override init(frame: CGRect) {
        super.init(frame: frame)
        
        setupUI()
        
    }
    
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    private func setupUI() {
        addSubviews(iconImageView, titleLabel)
        iconImageView.snp.makeConstraints { make in
            make.top.equalTo(5)
            make.centerX.equalToSuperview()
        }
        titleLabel.snp.makeConstraints { make in
            make.top.equalTo(iconImageView.snp.bottom).offset(6)
            make.left.right.equalToSuperview()
            make.bottom.equalToSuperview().offset(-ScreenSize.safeAreaInsets.bottom)
        }
    }
    func setIconImageView(icon: String, title: String, titleTopOffset: CGFloat = 6) {
        iconImageView.image = UIImage(named: icon)
        titleLabel.text = title
        titleLabel.snp.updateConstraints { make in
            make.top.equalTo(iconImageView.snp.bottom).offset(titleTopOffset)
        }
    }
    func setTitle(color: UIColor) {
        titleLabel.textColor = color
    }
    //=================================================================
    //                            lazy
    //=================================================================
    // MARK: - lazy
    private lazy var iconImageView: UIImageView = {
        let imageView = UIImageView(frame: .zero)
        return imageView
    }()
    private lazy var titleLabel: UILabel = {
        let label = UILabel()
        label.text = ""
        label.textColor = .lxs.hex("#A8ADB3")
        label.font = .lxs.font(size: 10)
        label.textAlignment = .center
        return label
    }()
}
